/*
 * @Author: 吴世扬 18368095041@163.com
 * @Date: 2025-02-19 16:59:03
 * @LastEditors: 吴世扬 18368095041@163.com
 * @LastEditTime: 2025-02-19 17:16:18
 * @FilePath: /vue3-admin-server/src/common/dto/role.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import { IsString, IsNumber, IsNotEmpty, IsArray } from 'class-validator';

import { PageDTO } from './page';
import { RoleEntity } from 'src/entities/role.entity';

export class RoleListDTO extends PageDTO<RoleEntity> {
    @IsString({ message: '角色名称必须为字符串' })
    name?: string;
}

export class RoleDTO {
    @IsNumber(undefined, {
        message: '角色id必须为数字'
    })
    id?: number;

    @IsNotEmpty({ message: '角色名称不能为空' })
    @IsString({ message: '角色名称必须为字符串' })
    name: string;

    @IsNotEmpty({ message: '角色描述不能为空' })
    @IsString({ message: '角色描述必须为字符串' })
    description?: string;

    @IsArray({ message: '菜单id列表必须为数组' })
    @IsNumber({}, { each: true, message: '菜单id列表中的每个元素必须为数字' })
    menuIds?: number[];
}
